<p class="Paragraph">The <span class="T1">If...Then</span> statement is used to execute program blocks depending on given conditions. When <help:productname xmlns:help="http://openoffice.org/2000/help">%PRODUCTNAME</help:productname> Basic encounters an <span class="T1">If</span> statement, the condition is tested. If True, all subsequent statements up to the next <span class="T1">Else</span> or <span class="T1">ElseIf</span> statement are executed. If the condition is False, and an <span class="T1">ElseIf</span> statement follows, <help:productname xmlns:help="http://openoffice.org/2000/help">%PRODUCTNAME</help:productname> Basic tests the next condition and executes the following statements if the condition is True. If False, the program continues either with the next <span class="T1">ElseIf</span> or <span class="T1">Else</span> <text:s text:c="" xmlns:text="http://openoffice.org/2000/text"/>statement. Statements following <span class="T1">Else</span> are executed only if none of the previously tested conditions were True. After all conditions have been evaluated, and the corresponding statements executed, the program continues with the statement following <span class="T1">EndIf</span>.</p>
<p class="Paragraph">Multiple <span class="T1">If...Then</span> statements may be nested.</p>
<p class="Paragraph"><span class="T1">Else</span> and <span class="T1">ElseIf</span> statements are optional.</p>
<p class="TextInTable">You can use <span class="T1">GoTo</span> and <span class="T1">GoSub</span> to jump out of an <span class="T1">If...Then</span> block, but not to jump into an <span class="T1">If...Then</span> structure.</p>
</span></th></tr></table>
<p class="Paragraph"/>
<p class="Paragraph">The following example enables you to enter the expiration date of a product, and returns whether the expiration date has passed.</p>
<p class="P2">Example:</p>
<p class="PropText">Sub ExampleIfThenDate</p>
<p class="PropText">Dim sDate as String</p>
<p class="PropText">Dim sToday as String</p>
<p class="PropText"/>
<p class="PropText">sDate = InputBox("Enter the expiration date (MM.DD.YYYY)")</p>